package com.example.shoppinglist;

import java.math.BigDecimal;

//where we store an item in a list
public class ShoppingItem  {

	//what the item is called 
	private String name;
	//the value of the item
	private BigDecimal cost;
	private long id;
	private String url;

	//shopping item is only created with a name because 
	//the user doesn't add a cost at the same time as adding an item to the list
	public ShoppingItem(String name) {
		this.name = name;
		this.cost = BigDecimal.ZERO;
	}

	public ShoppingItem(String name, BigDecimal cost) {
		this.name = name;
		this.cost = cost;
	}

	public ShoppingItem(String name, BigDecimal cost, String url) {
		this.name = name;
		this.cost = cost;
		this.url = url;
	}

	public BigDecimal getCost() {
		return cost;
	}

	public void setCost(BigDecimal cost) {
		this.cost = cost;
	}

	public String getName() {
		return name;
	}

	public long getId(){
		return id;
	}
	//overrides the string so the array adapter knows what to show in each list item
	@Override
	public String toString() {
		if(cost!= null){
			return name + "  cost: " + cost.toString();
		}
		return name;
	}

	public void setId(long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl(){
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
}
